<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>给组件绑定原生事件</title>
    <script src="../../vue.js"></script>
</head>

<body>
    <div id="app">
        <child @click.native='divClick'></child> <!-- 给组件绑定原生事件只需要在@click后面加上.native就表示要触发原生事件,就不需要通过子组件触发父组件的事件 -->
    </div>

    <script>
        Vue.component('child', {
            template: '<div>Child</div>'
        });

        const app = new Vue({
            el: '#app',
            methods: {
                divClick: function () {
                    alert('click');
                }
            },
        })
    </script>
</body>

</html>